﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace LanZhouBeefNoodles.Models
{
    /// <summary>
    /// 假数据生成工具
    /// </summary>
    public static class DbInitializer
    {
        public static void Seed(AppDbContext context)
        {
            if (!context.Noodles.Any())
            {
                context.AddRange
                (
                    new Noodle { Name = "毛细", Price = 12, ShortDescription = "如发丝般细", LongDescription = "真的好细好细好细啊", ImageURL = "/images/毛细.png" },
                    new Noodle { Name = "细", Price = 10, ShortDescription = "普通细", LongDescription = "还是挺细的", ImageURL = "/images/细.png" },
                    new Noodle { Name = "三细", Price = 11, ShortDescription = "有点粗了", LongDescription = "比细的粗点，比二细细点", ImageURL = "/images/三细.png" },
                    new Noodle { Name = "二细", Price = 10, ShortDescription = "粗了", LongDescription = "粗的才有嚼劲", ImageURL = "/images/二细.png" },
                    new Noodle { Name = "二柱子", Price = 11, ShortDescription = "太粗了", LongDescription = "粗得快咬不动了", ImageURL = "/images/二柱子.png" },
                    new Noodle { Name = "韭叶子", Price = 12, ShortDescription = "扁的", LongDescription = "韭猜叶一样宽", ImageURL = "/images/韭叶子.png" },
                    new Noodle { Name = "薄宽", Price = 11, ShortDescription = "开始宽了", LongDescription = "比韭叶宽一点，比大宽窄一点", ImageURL = "/images/薄宽.png" },
                    new Noodle { Name = "大宽", Price = 10, ShortDescription = "裤带面", LongDescription = "比嘴还宽了", ImageURL = "/images/大宽.png" },
                    new Noodle { Name = "荞麦棱子", Price = 15, ShortDescription = "立方体的", LongDescription = "好像知道师傅怎么拉出来的", ImageURL = "/images/荞麦棱子.png" },
                    new Noodle { Name = "一窝丝", Price = 15, ShortDescription = "这是啥", LongDescription = "我也没吃过", ImageURL = "/images/一窝丝.png" }
                );
                context.SaveChanges();
            }

            if (!context.Feedbacks.Any())
            {
                context.AddRange
                (
                    new Feedback { Name = "张三", Email = "zhangsan@163.com", Message = "很好吃啊，下次还来", CreateDateUTC = DateTime.Now },
                    new Feedback { Name = "李四", Email = "lisi@163.com", Message = "第二次来了，大爱", CreateDateUTC = DateTime.Now },
                    new Feedback { Name = "王五", Email = "wangwu@163.com", Message = "好吃啊，我绝对不是托", CreateDateUTC = DateTime.Now }
                );
                context.SaveChanges();
            }

        }
    }
}
